\hypertarget{classec_1_1Loop}{\section{ec\-:\-:Loop Class Reference}
\label{classec_1_1Loop}\index{ec\-::\-Loop@{ec\-::\-Loop}}
}


事件循环，对event\-\_\-base的封装。  




{\ttfamily \#include $<$loop.\-h$>$}

Inheritance diagram for ec\-:\-:Loop\-:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=3.000000cm]{classec_1_1Loop}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classec_1_1Loop_ab104699b3b40815f32e5272e85fb01d7}{\hyperlink{classec_1_1Loop_ab104699b3b40815f32e5272e85fb01d7}{operator event\-\_\-base $\ast$} () const }\label{classec_1_1Loop_ab104699b3b40815f32e5272e85fb01d7}

\begin{DoxyCompactList}\small\item\em 转换为event\-\_\-base $\ast$指针 \end{DoxyCompactList}\item 
\hypertarget{classec_1_1Loop_af62f9eae725eda092cc52168bdcb9b53}{event\-\_\-base $\ast$ \hyperlink{classec_1_1Loop_af62f9eae725eda092cc52168bdcb9b53}{ev} () const }\label{classec_1_1Loop_af62f9eae725eda092cc52168bdcb9b53}

\begin{DoxyCompactList}\small\item\em 获取event\-\_\-base $\ast$指针 \end{DoxyCompactList}\item 
\hypertarget{classec_1_1Loop_ae60730f9a1e07de6039de8008293769a}{uint32\-\_\-t \hyperlink{classec_1_1Loop_ae60730f9a1e07de6039de8008293769a}{id} () const }\label{classec_1_1Loop_ae60730f9a1e07de6039de8008293769a}

\begin{DoxyCompactList}\small\item\em 获得自动生成的\-Id号 \end{DoxyCompactList}\item 
\hypertarget{classec_1_1Loop_a134b0eb8eaa83270eb375df11160bea5}{bool \hyperlink{classec_1_1Loop_a134b0eb8eaa83270eb375df11160bea5}{is\-Thread} () const }\label{classec_1_1Loop_a134b0eb8eaa83270eb375df11160bea5}

\begin{DoxyCompactList}\small\item\em 是否是以新线程在运行 \end{DoxyCompactList}\item 
bool \hyperlink{classec_1_1Loop_a5e4e5650fbd4f1716429205c84ca51fd}{start} (bool new\-Thread=true)
\begin{DoxyCompactList}\small\item\em 启动事件循环 \end{DoxyCompactList}\item 
void \hyperlink{classec_1_1Loop_a476329b5b1b32a9d91957fdf820ed35b}{wait} ()
\begin{DoxyCompactList}\small\item\em 等待时间循环(线程)结束 \end{DoxyCompactList}\item 
void \hyperlink{classec_1_1Loop_aa96af9467ac7882e3cea7a4dcb51005a}{stop} (bool waiting=true)
\begin{DoxyCompactList}\small\item\em 停止事件循环 \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
static \hyperlink{classec_1_1Loop}{Loop} $\ast$ \hyperlink{classec_1_1Loop_abb797bdabdefdff5b6cc3f2b1b249747}{cur\-Loop} ()
\begin{DoxyCompactList}\small\item\em 返回当前线程的\-Loop \end{DoxyCompactList}\item 
static \hyperlink{classec_1_1Loop}{Loop} $\ast$ \hyperlink{classec_1_1Loop_a459fada2bbc382637fab88b3ce914d46}{get} (uint32\-\_\-t \hyperlink{classec_1_1Loop_ae60730f9a1e07de6039de8008293769a}{id})
\begin{DoxyCompactList}\small\item\em 根据id查找\-Loop \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
virtual bool \hyperlink{classec_1_1Loop_ab09acf916e8d3ad94cc2ceb483b1cac6}{on\-Before\-Start} ()
\begin{DoxyCompactList}\small\item\em 启动前触发 \end{DoxyCompactList}\item 
virtual void \hyperlink{classec_1_1Loop_ab50d820e5c09ef53af2aa97a1912025a}{on\-Before\-Loop} ()
\begin{DoxyCompactList}\small\item\em 事件循环运行前触发 \end{DoxyCompactList}\item 
virtual void \hyperlink{classec_1_1Loop_a9d3fec1a0d05dfdb73ceee20b6fd55b0}{on\-After\-Loop} ()
\begin{DoxyCompactList}\small\item\em 事件循环结束后触发 \end{DoxyCompactList}\item 
virtual void \hyperlink{classec_1_1Loop_aa52a4ac0232b307a08e7857748ebdd3f}{on\-After\-Stop} ()
\begin{DoxyCompactList}\small\item\em 停止后触发 \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
事件循环，对event\-\_\-base的封装。 

类本身是线程安全的，然而事件循环只能运行在一个线程中。 如果没有已注册的事件，事件则会自动结束 

\subsection{Member Function Documentation}
\hypertarget{classec_1_1Loop_abb797bdabdefdff5b6cc3f2b1b249747}{\index{ec\-::\-Loop@{ec\-::\-Loop}!cur\-Loop@{cur\-Loop}}
\index{cur\-Loop@{cur\-Loop}!ec::Loop@{ec\-::\-Loop}}
\subsubsection[{cur\-Loop}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Loop} $\ast$ ec\-::\-Loop\-::cur\-Loop (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [static]}}}\label{classec_1_1Loop_abb797bdabdefdff5b6cc3f2b1b249747}


返回当前线程的\-Loop 

\begin{DoxyReturn}{Returns}
当前线程\-Loop指针，没有\-Loop则\-N\-U\-L\-L 
\end{DoxyReturn}
\hypertarget{classec_1_1Loop_a459fada2bbc382637fab88b3ce914d46}{\index{ec\-::\-Loop@{ec\-::\-Loop}!get@{get}}
\index{get@{get}!ec::Loop@{ec\-::\-Loop}}
\subsubsection[{get}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Loop} $\ast$ ec\-::\-Loop\-::get (
\begin{DoxyParamCaption}
\item[{uint32\-\_\-t}]{id}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [static]}}}\label{classec_1_1Loop_a459fada2bbc382637fab88b3ce914d46}


根据id查找\-Loop 

\begin{DoxyReturn}{Returns}
Loop指针 
\end{DoxyReturn}
\hypertarget{classec_1_1Loop_a9d3fec1a0d05dfdb73ceee20b6fd55b0}{\index{ec\-::\-Loop@{ec\-::\-Loop}!on\-After\-Loop@{on\-After\-Loop}}
\index{on\-After\-Loop@{on\-After\-Loop}!ec::Loop@{ec\-::\-Loop}}
\subsubsection[{on\-After\-Loop}]{\setlength{\rightskip}{0pt plus 5cm}void ec\-::\-Loop\-::on\-After\-Loop (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [protected]}, {\ttfamily [virtual]}}}\label{classec_1_1Loop_a9d3fec1a0d05dfdb73ceee20b6fd55b0}


事件循环结束后触发 

运行在事件循环所在线程 \hypertarget{classec_1_1Loop_aa52a4ac0232b307a08e7857748ebdd3f}{\index{ec\-::\-Loop@{ec\-::\-Loop}!on\-After\-Stop@{on\-After\-Stop}}
\index{on\-After\-Stop@{on\-After\-Stop}!ec::Loop@{ec\-::\-Loop}}
\subsubsection[{on\-After\-Stop}]{\setlength{\rightskip}{0pt plus 5cm}void ec\-::\-Loop\-::on\-After\-Stop (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [protected]}, {\ttfamily [virtual]}}}\label{classec_1_1Loop_aa52a4ac0232b307a08e7857748ebdd3f}


停止后触发 

运行在调用stop时所在的线程，一般实现此函数处理启动前的准备工作 \hypertarget{classec_1_1Loop_ab50d820e5c09ef53af2aa97a1912025a}{\index{ec\-::\-Loop@{ec\-::\-Loop}!on\-Before\-Loop@{on\-Before\-Loop}}
\index{on\-Before\-Loop@{on\-Before\-Loop}!ec::Loop@{ec\-::\-Loop}}
\subsubsection[{on\-Before\-Loop}]{\setlength{\rightskip}{0pt plus 5cm}void ec\-::\-Loop\-::on\-Before\-Loop (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [protected]}, {\ttfamily [virtual]}}}\label{classec_1_1Loop_ab50d820e5c09ef53af2aa97a1912025a}


事件循环运行前触发 

运行在事件循环所在线程 

Reimplemented in \hyperlink{classec_1_1FrameLoop_a8b20b1f76ed9020484a73faa80e35eb5}{ec\-::\-Frame\-Loop}.

\hypertarget{classec_1_1Loop_ab09acf916e8d3ad94cc2ceb483b1cac6}{\index{ec\-::\-Loop@{ec\-::\-Loop}!on\-Before\-Start@{on\-Before\-Start}}
\index{on\-Before\-Start@{on\-Before\-Start}!ec::Loop@{ec\-::\-Loop}}
\subsubsection[{on\-Before\-Start}]{\setlength{\rightskip}{0pt plus 5cm}bool ec\-::\-Loop\-::on\-Before\-Start (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [protected]}, {\ttfamily [virtual]}}}\label{classec_1_1Loop_ab09acf916e8d3ad94cc2ceb483b1cac6}


启动前触发 

运行在调用start时所在的线程，一般实现此函数处理启动前的准备工作。 \begin{DoxyReturn}{Returns}
返回false幀 
\end{DoxyReturn}
\hypertarget{classec_1_1Loop_a5e4e5650fbd4f1716429205c84ca51fd}{\index{ec\-::\-Loop@{ec\-::\-Loop}!start@{start}}
\index{start@{start}!ec::Loop@{ec\-::\-Loop}}
\subsubsection[{start}]{\setlength{\rightskip}{0pt plus 5cm}bool ec\-::\-Loop\-::start (
\begin{DoxyParamCaption}
\item[{bool}]{new\-Thread = {\ttfamily true}}
\end{DoxyParamCaption}
)}}\label{classec_1_1Loop_a5e4e5650fbd4f1716429205c84ca51fd}


启动事件循环 


\begin{DoxyParams}{Parameters}
{\em new\-Thread} & 是否启动新线程运行时间循环\\
\hline
\end{DoxyParams}
在当前线程运行会阻塞当前线程直到时间循环结束，\begin{DoxySeeAlso}{See Also}
\hyperlink{classec_1_1Loop_ab09acf916e8d3ad94cc2ceb483b1cac6}{on\-Before\-Start} 
\end{DoxySeeAlso}
\begin{DoxyReturn}{Returns}
是否成功 
\end{DoxyReturn}
\hypertarget{classec_1_1Loop_aa96af9467ac7882e3cea7a4dcb51005a}{\index{ec\-::\-Loop@{ec\-::\-Loop}!stop@{stop}}
\index{stop@{stop}!ec::Loop@{ec\-::\-Loop}}
\subsubsection[{stop}]{\setlength{\rightskip}{0pt plus 5cm}void ec\-::\-Loop\-::stop (
\begin{DoxyParamCaption}
\item[{bool}]{waiting = {\ttfamily true}}
\end{DoxyParamCaption}
)}}\label{classec_1_1Loop_aa96af9467ac7882e3cea7a4dcb51005a}


停止事件循环 

如果以新线程运行的，则会停止新线程。 
\begin{DoxyParams}{Parameters}
{\em waiting} & 是否直到运行所有激活事件的回调才退出 \\
\hline
\end{DoxyParams}
\hypertarget{classec_1_1Loop_a476329b5b1b32a9d91957fdf820ed35b}{\index{ec\-::\-Loop@{ec\-::\-Loop}!wait@{wait}}
\index{wait@{wait}!ec::Loop@{ec\-::\-Loop}}
\subsubsection[{wait}]{\setlength{\rightskip}{0pt plus 5cm}void ec\-::\-Loop\-::wait (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{classec_1_1Loop_a476329b5b1b32a9d91957fdf820ed35b}


等待时间循环(线程)结束 

不是以新线程运行的调用此函数不会有任何效果 \begin{DoxySeeAlso}{See Also}
bool Loop\-::start\-Thread() 
\end{DoxySeeAlso}


The documentation for this class was generated from the following files\-:\begin{DoxyCompactItemize}
\item 
include/ec/loop.\-h\item 
src/loop.\-cpp\end{DoxyCompactItemize}
